#!/sbin/openrc-run

PIDFILE=/var/run/janus.pid

depend() {
	need net
}

start_pre() {
	checkpath -f -o $JANUS_USER:$JANUS_GROUP -m644 /var/log/janus.log
	if [ ! -f /etc/janus/janus.jcfg ] ; then
		eerror "/etc/janus/janus.jcfg file doesn't exists!"
		return 1
	fi

}

start() {
	ebegin "Starting Janus gateway server"
	start-stop-daemon --start --make-pidfile --exec /usr/bin/janus \
		--pidfile "${PIDFILE}" --background --quiet \
		--user "${JANUS_USER}" \
		-- ${JANUS_OPTS} -L /var/log/janus.log 
	eend $?
}

stop() {
	ebegin "Stopping Janus gateway server"
	start-stop-daemon --stop --quiet --pidfile "${PIDFILE}"
	eend $?
}

